/*
 * Copyright (c) Soon.Liao 2024. All rights reserved.
 * @Author: soon.liao
 * @Date: 2024-12-03 21:17:00
 * @LastEditors: soon.liao
 * @LastEditTime: 2024-12-04 20:35:38
 * @FilePath: /near_link_sdk/applications/sample/wifi-iot/app/rgb_controller/oled/ssd1306_show.c
 * @Description: Create Date : 2024
 * NA
 */
#include "ssd1306.h"
#include "ssd1306_show.h"
#include "soc_osal.h"

void oled_show_title(void)
{
    ssd1306_set_cursor(0, 0);
#if defined(CONFIG_SAMPLE_SUPPORT_SLE_RGB_MASTER_SERVER)
    ssd1306_draw_string("Paj7620U2", g_font_7x10, WHITE);
#elif defined(CONFIG_SAMPLE_SUPPORT_SLE_RGB_MASTER_CLIENT)
    ssd1306_draw_string("Sk9822", g_font_7x10, WHITE);
#endif
    ssd1306_update_screen();
}

void oled_show_sle_num(uint8_t num)
{
    int x = 70;
    int y = 0;
    ssd1306_set_cursor(x, y);
    ssd1306_printf("sle:%d", num);
}

void oled_show_ip(char *ip)
{
    char tmp_data[18];
    int x = 0;
    int y = 15;
    // Use space character to clear Oled display
    memset(tmp_data, CHAR_SPACE, MAX_FONT_7_10_IN_ONE_LINE);
    memcpy(tmp_data, ip, strlen(ip));
    tmp_data[MAX_FONT_7_10_IN_ONE_LINE] = CHAR_END;
    ssd1306_set_cursor(x, y);
    ssd1306_draw_string(tmp_data, g_font_7x10, WHITE);
    ssd1306_update_screen();
    osal_printk("oled_show_ip done! :: %s\r\n", ip);
    free(tmp_data);
}

void oled_show_sle_mac(unsigned char *local_addr)
{
    int x = 0;
    int y = 30;
    ssd1306_set_cursor(x, y);
    ssd1306_printf("%02X:%02X:%02X:%02X:%02X:%02X", local_addr[0], local_addr[1], local_addr[2], local_addr[3],
                   local_addr[4], local_addr[5]);
}

void oled_show_cmd(char *data, uint32_t len)
{
    int x = 0;
    int y = 45;
    char tmp_data[MAX_FONT_7_10_IN_ONE_LINE];
    // Use space character to clear Oled display
    memset(tmp_data, CHAR_SPACE, MAX_FONT_7_10_IN_ONE_LINE);
    memcpy(tmp_data, data, len);
    tmp_data[MAX_FONT_7_10_IN_ONE_LINE] = CHAR_END;
    ssd1306_set_cursor(x, y);
    ssd1306_draw_string(tmp_data, g_font_7x10, WHITE);
    ssd1306_update_screen();
    osal_printk("oled_show_cmd data:%s len:%d\n", data, len);
    free(tmp_data);
}
